package com.hzit.listener;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

/**
 * 类名：
 * 作者：WF
 * 功能：监听HttpSession会话及会话的属性值变化.
 */
@WebListener
public class MySessionListener implements HttpSessionListener, HttpSessionAttributeListener {
	//1. 以下丙个是对HttpSession对象进行监听
	@Override
	public void sessionCreated(HttpSessionEvent se) {
		System.out.println("session 创建完成。");
	}

	@Override
	public void sessionDestroyed(HttpSessionEvent se) {
		System.out.println("session 销毁完成。");
	}
	//2. 对下三个是对HttpSession中的属性值进行监听
	@Override
	public void attributeAdded(HttpSessionBindingEvent event) {
		System.out.println("为session添加属性值。");
	}

	@Override
	public void attributeRemoved(HttpSessionBindingEvent event) {
		System.out.println("为session移除属性值。");
	}

	@Override
	public void attributeReplaced(HttpSessionBindingEvent event) {

	}

}
